#include <iostream>
#include <chrono>
#include <random>
#include <complex>
#include "farrow.h"

typedef std::complex<float> Complex;

void test_cpp11_version() {
    // 生成测试信号 (C++11随机数引擎)
    std::mt19937 gen(42); // 固定种子用于重现性
    std::normal_distribution<float> dist(0.0f, 0.1f);

    std::vector<Complex> iq_data(1000000);
    for (auto& sample : iq_data) {
        sample = Complex(dist(gen), dist(gen));
    }

    // 创建插值器
    FarrowInterpolatorIQ_Cpp11 interpolator;

    // 计时 (C++11 chrono)
    auto start = std::chrono::high_resolution_clock::now();
    //auto resampled = interpolator.resample(iq_data, 192, 100); // 1.92倍上采样
    auto resampled = interpolator.resample(iq_data, 6144, 6250); // 1.92倍上采样
    auto end = std::chrono::high_resolution_clock::now();

    // 性能输出
    auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start);
    std::cout << "C++11版本处理 " << iq_data.size() << " 个IQ样本\n"
        << "耗时: " << duration.count() << " ms\n"
        << "输出: " << resampled.size() << " 个样本\n";

    // 验证前几个输出样本
    std::cout << "\n前5个输出样本:\n";
    for (int i = 0; i < 5; ++i) {
        std::cout << resampled[i].real() << " + "
            << resampled[i].imag() << "j\n";
    }
}

int test_farrow() {
    test_cpp11_version();
    return 0;
}